package com.tianhui.consignortwofei.other.auth.recognition.process;

import android.text.TextUtils;

import com.tianhui.consignortwofei.mvp.model.enty.RecognitionInfo;
import com.tianhui.consignortwofei.mvp.model.enty.SelectPhotoInfo;
import com.tianhui.consignortwofei.mvp.model.enty.authLicense.VehicleLicenseInfo;
import com.tianhui.consignortwofei.mvp.model.enty.ocrResult.vehicleLicense.VehicleLicenseResult;
import com.tianhui.consignortwofei.other.auth.inte.ProcessCallback;
import com.tianhui.consignortwofei.other.auth.recognition.recognitionResultProcess.VehicleLicenseOcrResultProcess;

/**
 * @author fgs
 * @date 2021/5/13
 * @description
 **/
public class VehicleBackRecognitionProcess implements IRecognitionProcess<VehicleLicenseResult, VehicleLicenseInfo> {

    @Override
    public void recognitionProcess(RecognitionInfo<VehicleLicenseResult> recognitionInfo, SelectPhotoInfo selectPhotoInfo, ProcessCallback<VehicleLicenseInfo> processCallback) {

        String errorMessage = "不是行驶证副页或图片太模糊，请重新上传";
        VehicleLicenseResult licenseData = recognitionInfo.info;
        if (licenseData != null) {
            VehicleLicenseOcrResultProcess resultProcess = new VehicleLicenseOcrResultProcess();
            VehicleLicenseInfo resultInfo = resultProcess.getVehicleOcrResult(licenseData,false);
            if (resultInfo != null && !TextUtils.isEmpty(resultInfo.plateNo)) {
                resultInfo.path = selectPhotoInfo.filePath;
                resultInfo.pictureId = selectPhotoInfo.pictureId;
                processCallback.processSuccess(resultInfo);
            } else {
//                ToastUtil.showShortToast(errorMessage);
//                processCallback.processFailed();
                processCallback.processSuccess(resultInfo);
            }

        }else {
//            ToastUtil.showShortToast(errorMessage);
//            processCallback.processFailed();
            processCallback.processSuccess(null);
        }

    }

}
